home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / include / incl98.zoo / assert.h < prev    next >
C/C++ Source or Header  |  1994-03-29  |  1KB  |  61 lines

  1. /*
  2.  * assert.h
  3.  *    sec 4.2 ansi draft
  4.  */
  5.  
  6. /* Allow this file to be included multiple times
  7.    with different settings of NDEBUG.  */
  8. #undef assert
  9. #undef __assert
  10.  
  11. #ifndef _COMPILER_H
  12. #include <compiler.h>
  13. #endif
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. __EXTERN void __eprintf __PROTO((const char *expression, const long line,
  20.                  const char *filename));
  21. __EXTERN __EXITING abort __PROTO((void)) __NORETURN;
  22.  
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26.  
  27. #ifdef NDEBUG
  28. #define    assert(cond) ((void *) 0)
  29. #define __assert(cond) ((void *) 0)
  30. #else /* not NDEBUG */
  31.  
  32. #if __STDC__
  33. #define assert(cond) \
  34. ((cond) ? 0 : \
  35.     ( __eprintf(#cond,(long)(__LINE__), __FILE__), abort(), 0 ))
  36. #define __assert(cond) \
  37. if(!(cond)) \
  38.     { __eprintf(#cond,(long)(__LINE__), __FILE__); abort(); }
  39. #else /* not __STDC__ */
  40.  
  41. #ifndef __SOZOBON__
  42. /* There's a bug in Sozobon 2.0 whereby __LINE__ & __FILE__ are defined but
  43.  * testing #ifndef __?I?E__ comes out as if they aren't. */
  44. #ifndef __LINE__
  45. #define __LINE__ 0
  46. #endif
  47. #ifndef __FILE__
  48. #define __FILE__ "unknown"
  49. #endif
  50. #endif /* not __SOZOBON__ */
  51.  
  52. #define assert(cond) \
  53. ((cond) ? 0 : \
  54.     ( __eprintf("cond", (long)(__LINE__), __FILE__), abort(), 0))
  55. #define __assert(cond) \
  56. if(!(cond)) \
  57.     { __eprintf("cond", (long)(__LINE__), __FILE__); abort(); }
  58. #endif /* not __STDC__ */
  59.  
  60. #endif /* not NDEBUG */
  61.